package com.oyb.servlet;

import com.oyb.entity.Page;
import com.oyb.service.StudentServies;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = "/stuquerypage")
public class Stuquerypage extends HttpServlet {
    private StudentServies studentServies = new StudentServies();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String page = req.getParameter("page");
        String pageSize = req.getParameter("pageSize");
        //如果是从其他servlet跳转的会没有参数，我们可以给个默认值
        if(page == null || pageSize == null){
            page = "1";
            pageSize = "3";
        }
        Page p = new Page();
        p.setPage(Integer.parseInt(page));
        p.setPageSize(Integer.parseInt(pageSize));

        p = studentServies.queryStuPage(p);
        req.setAttribute("pagestudent",p);
        req.getRequestDispatcher("querystudent.jsp").forward(req,resp);



    }
}
